<?php

namespace App\Models;

class HelpCategorys extends Base
{
    protected $table = 'help_categorys';


    protected $fillable = [
        'id','name','pid','before_icon','after_icon','sort','status','created_at','updated_at'
    ];

    /**
     * 获取列表
     * @return mixed
     */
    protected function getList(){
        $lists = $this->where('status','<>',-1)->orderBy('sort','asc')->get()->toArray();
        $menus = $this->toFormatTree($lists,'name');
        return $menus;
    }

    /**
     * 获取级联列表
     * @return mixed
     */
    protected function getCascaderList(){
        $lists = $this->where('status','<>',-1)->orderBy('sort','asc')
            ->get(['id as value','name as label','pid', 'before_icon', 'after_icon'])->toArray();
        return $this->listToTree($lists, 'value');
    }

    /**
     * 获取各级分类
     * @return mixed
     */
    protected function getcates($params, $fields = ['*']){
        return $this->select($fields)->where($params)->orderBy('sort','asc')->where('status','<>',-1)->get();
    }

}
